package com.cictec.middleware.gps.engine;

import java.util.HashMap;
import java.util.Map;

import com.cictec.middleware.commons.utils.Constants;
import com.cictec.middleware.gps.engine.TimingPoint;

/**
 * 实时对象超类，实时对象动态数据、实时对象动态持久数据保存
 * 
 * @author Administrator
 *
 */
public abstract class AbstractBusInstance extends TimingPoint {

	/** */
	private static final long serialVersionUID = 1486450554265350430L;

	/** 前一个进出站信息 */
	private TimingPoint preStation;
	/** 当前进出站信息 */
	private TimingPoint currentStation;
	
	/** 当前实时数据 【进出站信息 瞬时数据】 */
	public TimingPoint getCurrentStation() {
		return currentStation;
	}

	/** 当前实时数据 【进出站信息 瞬时数据】 */
	public void setCurrentStation(TimingPoint enterOutStation) {
		this.preStation = currentStation;
		this.currentStation = copyTimingPoint(enterOutStation);
//		System.out.println(preStation.getStationLineSeqOrg() + "\t"+preStation.getStationEnterOut() + "\t" + preStation.getGatherTime());
//		System.out.println(currentStation.getStationLineSeqOrg() + "\t"+currentStation.getStationEnterOut() + "\t" + currentStation.getGatherTime());
	}
	/** 前一个进出站信息 */
	public TimingPoint getPreStation() {
		return preStation;
	}
//	/** 前一个进出站信息 */
//	public void setPreStation(TimingPoint preStation) {
//		this.preStation = copyTimingPoint(preStation);
//	}
	
	/** 当前趟次开始点 */
	private TimingPoint currentTripStartPoint;
	/** 当前趟次开始点 */
	public void setCurrentTripStartPoint(TimingPoint point) {
		this.currentTripStartPoint = copyTimingPoint(point);
	}
	/** 当前趟次开始点 */
	public TimingPoint getCurrentTripStartPoint() {
		return currentTripStartPoint;
	}
	
	private TimingPoint copyTimingPoint(TimingPoint timingPoint){
		TimingPoint point = null;
		if(timingPoint != null){
			point = new TimingPoint();
			point.setTime(timingPoint.getTime());
			point.setAttributes(timingPoint.getAttributes());
		}
		return point;
	}


	/** 最后一个速度为0的的位置*/
	private TimingPoint startStopPoint;

	public TimingPoint getStartStopPoint() {
		return startStopPoint;
	}

	public void setStartStopPoint(TimingPoint startStopPoint) {
		this.startStopPoint = copyTimingPoint(startStopPoint);
	}

	/**
	 * 车辆动态数据，附加状态（因为status每个信息上来会重置）
	 */
	// private Map<String, String> additionalStatus = new ConcurrentHashMap<String, String>();
	private Map<String, String> additionalStatus = new HashMap<String, String>();

	public Map<String, String> getAdditionalStatus() {
		return additionalStatus;
	}

	public void setAdditionalStatus(Map<String, String> additionalStatus) {
		this.additionalStatus = additionalStatus;
	}
	/**
	 * 【附加信息持久保存在实时对象中】
	 * @param additionalKey
	 * @param additionalValue
	 */
	public void setAdditionalStatus(String additionalKey, String additionalValue) {
		this.additionalStatus.put(additionalKey, additionalValue);
	}
	/**
	 * 【附加信息持久保存在实时对象中】
	 * @param additionalKey
	 * @return
	 */
	
	public String getAdditionalStatus(String additionalKey) {
		return additionalStatus.get(additionalKey);
	}
	/**
	 * 【附加信息持久保存】客流满载率
	 * @param fullloadRate
	 */
	public void setAdditionalPassenerflowFullloadRate(String fullloadRate){
		this.setAdditionalStatus(Constants.MSG_INFO_PASSENGERFLOW_FULLLOADRATE, fullloadRate);
	}
	

	
	/**
	 * 【附加信息持久保存】客流满载率
	 * @param fullloadRate
	 */
	public String getAdditionalPassenerflowFullloadRate(){
		return this.getAttribute(Constants.MSG_INFO_PASSENGERFLOW_FULLLOADRATE);
	}

}
